using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Entities;

namespace BUS
{
    public class tbDonHangBUS
    {
        public static void Insert_DonHang(tbDonHang donhang)
        {
            tbDonHangDAL donhangDAL = new tbDonHangDAL();
            donhangDAL.Insert(donhang);
        }
        public static void Update_DonHang(tbDonHang donhang)
        {
            tbDonHangDAL donhangDAL = new tbDonHangDAL();
            donhangDAL.Update(donhang);
        }
        public static void Delete_DonHang(int iD)
        {
            tbDonHangDAL donhangDAL = new tbDonHangDAL();
            donhangDAL.Delete(iD);
        }
        public static Entities.tbDonHang.tbDonHangCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbDonHangDAL donhangDAL = new tbDonHangDAL();
            return donhangDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static Entities.tbDonHang.tbDonHangCollection GetAll()
        {
            int total = 0;
            tbDonHangDAL donhangDAL = new tbDonHangDAL();
            return donhangDAL.Get("where 1=1", 0, 0, tbDonHang.tbDonHangColumns.IDDonHang.ToString(), "ASC", out total);
        }
        public static tbDonHang GetByID(int iD)
        {
            int total = 0;
            tbDonHangDAL donhangDAL = new tbDonHangDAL();
            tbDonHang.tbDonHangCollection donhangCollection = donhangDAL.Get("where " + tbDonHang.tbDonHangColumns.IDDonHang.ToString() + "=" + iD.ToString(), 0, 0, tbDonHang.tbDonHangColumns.IDDonHang.ToString(), "ASC", out total);
            if (donhangCollection.Count > 0)
                return donhangCollection[0];
            return null;
        }
    }
}
